
@echo off
if "%cd0%"=="" (
    set cd0=%cd%
)
if "%MEDIASOUP_LISTEN_IP%"=="" (
    for /f "tokens=16" %%a in ('ipconfig ^| find /i "ipv4"') do (
        set MEDIASOUP_LISTEN_IP=%%a
    )
)
@echo on

@echo off
set certs=%cd0%\demo\server\certs
if exist "%certs%\privkey.pem" goto end_certs
mkdir %certs%
cd %certs%
@echo on
openssl genrsa -out privkey.pem 2048
openssl req -new -x509 -key privkey.pem -out fullchain.pem -days 3650
:end_certs

cd %cd0%\demo\server
if exist config.js goto end_config
copy config.example.js config.js
:end_config

@echo off & cd %cd0%\demo\app & @echo on
start npm start

@echo off & cd %cd0%\demo\server & @echo on
call node server.js

@echo off & cd %cd0% & @echo on

@pause